<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

if(!defined('_joomleague_func_')){
  define('_joomleague_func_', 1);

  function _include(){
      
    $dirname = dirname(__FILE__) . '/classes';
    
    if ($dir = @opendir($dirname)) {
      require_once(sprintf("%s/%s",$dirname,"JLClass.class.php"));//has to be imported first
      while (($file = @readdir($dir)) !== false) {
        if (substr($file, -9) == 'class.php') {
          if (require_once(sprintf("%s/%s",$dirname,$file))) {
            //printf("%s/%s",$dirname,$file);
          }
          else {
            printf("could not include file: %s", $file);          
          }
        }
      }
  
      @closedir($dir);
    }
  }

  function mbiFormatDate( $date, $format="%x" ){
  	if ( $date != "0000-00-00" && ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $date, $regs ) ) {
  		$date = strftime( $format, mktime(0,0,0,$regs[2], $regs[3], $regs[1]));
  	} else $date = '-';
  	return $date;
  }
  
  function getAge($date) {
    
  	if ( $date != "0000-00-00" && ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $date, $regs ) ) {
      
      $intAge = date('Y') - $regs[1];
      if($regs[2] > date('m')) $intAge--;
      else{
        if($regs[2] == date('m')){
          if($regs[3] > date('d')) $intAge--; 
        }
      }
      return $intAge;
    }
    else return '-';
  }
  
}


_include();

?>

